<!DOCTYPE html>
<html
  layout:decorator="components/layout"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
>
<head>
  <title>关键词库</title>
</head>
<body>
<div
  layout:fragment="content"
  id="app" v-cloak
>
  <!--引入边框角-->
  <div class="container">

    <div class="myHeader">
      <div class="myHeader-title">
        关键词库
      </div>
      <div class="myHeader-tool">
        <el-button
          type="primary"
          size="mini"
          @click="addInfo"
          v-realm="'system-configuration:sys-keyword-repo:edit'"
        >新增
        </el-button>

        <el-button type="primary" icon="el-icon-search" size="mini" @click="toggle">高级搜索</el-button>

        &nbsp;
        所有词组:
        <el-select v-model="form.category" @change="searchPage" placeholder="请选择" size="mini" clearable>
          <el-option v-for="[key,val] in categoryMap" :label="val" :key="key" :value="key">
          </el-option>
        </el-select>

        &nbsp;
        所有状态:
        <el-select v-model="form.status" @change="searchPage" placeholder="请选择" size="mini" clearable>
          <el-option v-for="[key,val] in fieldFormatter.sysField.statusMap" :label="val" :key="key" :value="key">
          </el-option>
        </el-select>
      </div>
    </div>

    <el-row>
      <el-form label-width="100px" class="container-search" v-show="formShow">
        <el-row :gutter="10">
          <el-col :span="9">
            <el-form-item label="权重:">
              <el-input
                v-model="form.weight"
                clearable
                show-word-limit
                maxlength="30"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label-width="0">
              <rx-search-action
                v-model="form.weightAction"
              ></rx-search-action>
            </el-form-item>
          </el-col>

          <el-col :span="9">
            <el-form-item label="匹配次数:">
              <el-input
                v-model="form.matchCount"
                clearable
                show-word-limit
                maxlength="30"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label-width="0">
              <rx-search-action
                v-model="form.matchCountAction"
              ></rx-search-action>
            </el-form-item>
          </el-col>

          <el-col :span="9">
            <el-form-item label="关键字:">
              <el-input
                v-model="form.keyword"
                clearable
                show-word-limit
                maxlength="30"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label-width="0">
              <rx-search-action
                v-model="form.keywordAction"
              ></rx-search-action>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="创建时间:">
              <rx-range-date
                v-model="form.createTimeRange"
                @change="arr => changeRangeDate('createTimeStart', 'createTimeEnd')(arr)"
              ></rx-range-date>
            </el-form-item>
          </el-col>
        </el-row>

        <div style="text-align:center; margin-bottom:20px">
          <el-button type="primary" size="medium" @click="searchPage">查 找</el-button>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <el-button type="primary" size="medium" @click="resetPage">重 置</el-button>
        </div>
      </el-form>
    </el-row>

    <!--内容-->
    <my-table
      :data="page.records"
      :columns="columns"
      @handle-selection-change="selection"
      @handle-sort-change="sortChange"
    >
      <template #operating="scope">
        <span>
          <el-button
            v-show="scope.row.insId==null"
            size="mini"
            type="primary"
            @click.stop.prevent="updateInfo(scope.row)"
            v-realm="'system-configuration:sys-keyword-repo:edit'"
          >修改</el-button>
        </span>
        <span>
          <el-button
            v-show="scope.row.insId==null"
            size="mini"
            type="danger"
            @click.stop.prevent="del(scope.row)"
            v-realm="'system-configuration:sys-keyword-repo:edit'"
          >删除</el-button>
        </span>
      </template>
      <template #status="scope">
          <span>
              <img
                border="0"
                :src="statusImg(scope.row.status)"
                v-realm="'system-configuration:sys-keyword-repo:edit'"
              />
          </span>
      </template>
    </my-table>
    <div class="pagination">
      <el-pagination
        background
        @size-change="changeSize"
        @current-change="goto"
        :current-page="page.current"
        :page-sizes="[10, 20, 30]"
        :page-size="page.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="page.total"
      >
      </el-pagination>
      <div class="pagination-tool">
        <el-button
          size="mini"
          type="primary"
          @click="showFileSelector"
          v-realm="'system-configuration:sys-keyword-repo:edit'"
        >导入所有
        </el-button>
        <el-button
          size="mini"
          type="primary"
          @click="exportFile"
          v-realm="'system-configuration:sys-keyword-repo'"
        >导出所有
        </el-button>
        <el-button
          size="mini"
          type="danger"
          @click="deleteSelected"
          v-realm="'system-configuration:sys-keyword-repo:edit'"
        >删除
        </el-button>
      </div>
    </div>

    <import-excel
      :file-selector-show="fileSelectorShow"
      @import-file="importFile"
      @reset-file="resetFile"
      @download-template="downloadTemplate"
    ></import-excel>
  </div>

  <el-dialog
    :title="dtitle"
    width="30%"
    :visible.sync="dialogShow"
  >
    <el-form style="margin-left: 5px">
      <el-form-item
        label="关键词"
        :label-width="formLabelWidth"
      >
        <el-input v-model="formData.keyword"></el-input>
      </el-form-item>
      <el-form-item
        label="状态"
        :label-width="formLabelWidth"
      >
        <el-select
          v-model="formData.status"
          placeholder="请选择"
        >
          <el-option
            v-for="[k,v] in fieldFormatter.sysField.statusMap"
            :key="k"
            :label="v"
            :value="k"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item
        label="权重"
        :label-width="formLabelWidth"
      >
        <el-input v-model="formData.weight"></el-input>
      </el-form-item>

      <el-form-item
        label="匹配次数"
        :label-width="formLabelWidth"
      >
        <el-input v-model="formData.matchCount"></el-input>
      </el-form-item>
      <el-form-item
        label="关键词组"
        :label-width="formLabelWidth"
      >
        <el-select
          v-model="formData.category"
          placeholder="请选择"
        >
          <el-option
            v-for="[k,v] in categoryMap"
            :key="k"
            :label="v"
            :value="k"
          >
          </el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <div
      slot="footer"
      class="dialog-footer"
    >
      <el-button @click="dialogShow = false">取 消</el-button>
      <el-button
        type="primary"
        @click="updateOrAddData"
        v-realm="'system-configuration:sys-keyword-repo:edit'"
      >确 定
      </el-button>
    </div>
  </el-dialog>
</div>
<div layout:fragment="js">
  <script src="/static/js/module/system-config/model/SysKeywordRepo.js"></script>
  <script src="/static/js/module/system-config/api/SysBaseCodeApi.js"></script>
  <script src="/static/js/module/system-config/api/sysKeywordRepoApi.js"></script>
  <script src="/static/js/module/system-config/admin_keywords.js"></script>
</div>
</body>
</html>
